import { createRouter, createWebHistory } from "vue-router";

export const constantRouterMap = [
  {
    path: "/",
    name: "Index",
    component: () => import("@/views/Index.vue"),
    redirect: "/index",
    children: [
		{
		  path: "index",
		  name: "Index",
		  meta: {
		    title: "网站首页"
		  },
		  component: () => import("@/views/home/Index.vue")
		},
      {
        path: "course",
        name: "CourseStudy",
        meta: {
          title: "课程学习"
        },
        component: () => import("@/views/course/Index.vue")
      },
      {
        path: "course/onlineStudy/:id",
        name: "OnlineStudy",
        meta: {
          title: "在线学习"
        },
        component: () => import("@/views/course/OnlineStudy.vue")
      },
	  {
	    path: "course/comment/:id",
	    name: "Comment",
	    meta: {
	      title: "课程评论"
	    },
	    component: () => import("@/views/course/coursedetail/FComment.vue")
	  },
      {
        path: "course/courseList",
        name: "CourseList",
        meta: {
          title: "课程列表"
        },
        component: () => import("@/views/course/CourseList.vue")
      },
      {
        path: "/course/myCollect/:searchType",
        name: "CourseCollect",
        meta: {
          title: "我的收藏"
        },
        component: () => import("@/views/course/CourseList.vue")
      },
      {
        path: "/course/footprint/:searchType",
        name: "Footprint",
        meta: {
          title: "我的足迹"
        },
        component: () => import("@/views/course/CourseList.vue")
      },

      {
        path: "practice",
        name: "Practice",
        meta: {
          title: "题库练习"
        },
        component: () => import("@/views/practice/Index.vue")
      },
      {
        path: "practice/practiceMode/:id",
        name: "PracticeMode",
        meta: {
          title: "练习模式"
        },
        component: () => import("@/views/practice/PracticeMode.vue")
      },
      {
        path: "practice/onlinePractice/:id",
        name: "OnlinePractice",
        meta: {
          title: "在线练习"
        },
        component: () => import("@/views/practice/OnlinePractice.vue")
      },
      {
        path: "practice/userPracticeResult/:id",
        name: "UserPracticeResult",
        meta: {
          title: "练习结果"
        },
        component: () => import("@/views/practice/UserPracticeResult.vue")
      },

      {
        path: "exam",
        name: "ExamIndex",
        meta: {
          title: "考试列表"
        },
        component: () => import("@/views/exam/Index.vue")
      },
      {
        path: "exam/preview/:id",
        name: "ExamPreview",
        meta: {
          title: "考试预览"
        },
        component: () => import("@/views/exam/ExamPreview.vue")
      },

      {
        path: "news",
        name: "NewsIndex",
        meta: {
          title: "新闻资讯"
        },
        component: () => import("@/views/news/Index.vue")
      },
	  {
	    path: "about",
	    name: "About",
	    meta: {
	      title: "平台概况"
	    },
	    component: () => import("@/views/about/Index.vue")
	  },
      {
        path: "news/detail/:id",
        name: "NewsDetail",
        meta: {
          title: "资讯详情"
        },
        component: () => import("@/views/news/NewsDetail.vue")
      },
	  {
	    path: "articles/detail/:id",
	    name: "ArticlesDetail",
	    meta: {
	      title: "文章详情"
	    },
	    component: () => import("@/views/articles/NewsDetail.vue")
	  },
	  {
	    path: "training",
	    name: "Training",
	    meta: {
	      title: "培训项目"
	    },
	    component: () => import("@/views/training/Index.vue")
	  },
	  {
	    path: "/help",
	    name: "Help",
	    meta: {
	      title: "帮助中心"
	    },
	    component: () => import("@/views/help/Index.vue")
	  },
	  {
	    path: "contact",
	    name: "Contact",
	    meta: {
	      title: "联系我们"
	    },
	    component: () => import("@/views/contact/Index.vue")
	  },
      {
        path: "chatGPT",
        name: "ChatGPT",
        meta: {
          title: "智能助手"
        },
        component: () => import("@/views/ai/Index.vue")
      },

      {
        path: "userCenter",
        name: "UserCenter",
        meta: {
          title: "个人中心"
        },
        component: () => import("@/views/user/Index.vue"),
        redirect: "/userCenter/baseSetting",
        children: [
          {
            path: "baseSetting",
            name: "BaseSetting",
            meta: {
              title: "个人信息"
            },
            component: () => import("@/views/user/BaseSetting.vue")
          },
          {
            path: "accountSetting",
            name: "AccountSetting",
            meta: {
              title: "账号安全"
            },
            component: () => import("@/views/user/AccountSetting.vue")
          },
          {
            path: "practice/record",
            name: "PracticeRecord",
            meta: {
              title: "练习记录"
            },
            component: () => import("@/views/user/PracticeRecord.vue")
          },
          {
            path: "exam/examScore",
            name: "ExamScore",
            meta: {
              title: "考试成绩"
            },
            component: () => import("@/views/user/ExamScore.vue")
          },
          {
            path: "exam/examScore/userExamResult/:id",
            name: "UserCenterExamResult",
            meta: {
              title: "用户考试列表"
            },
            component: () => import("@/views/user/UserExamResult.vue")
          },
          {
            path: "course/studyRecord",
            name: "CourseStudyRecord",
            meta: {
              title: "课程学习记录"
            },
            component: () => import("@/views/user/CourseStudyRecord.vue")
          },
          {
            path: "course/studyProcess",
            name: "CourseStudyProcess",
            meta: {
              title: "课程学习进度"
            },
            component: () => import("@/views/user/CourseStudyProcess.vue")
          },
          {
            path: "myOrder",
            name: "MyOrder",
            meta: {
              title: "我的订单"
            },
            component: () => import("@/views/mall/ordercenter/MyOrder.vue")
          },
          {
            path: "myOrder/orderDetail/:orderSn",
            name: "OrderDetail",
            meta: {
              title: "订单详情"
            },
            component: () => import("@/views/mall/ordercenter/OrderDetail.vue")
          },
          {
            path: "myOrder/refund/:orderSn",
            name: "Refund",
            meta: {
              title: "订单退款"
            },
            component: () => import("@/views/mall/ordercenter/Refund.vue")
          },
          {
            path: "myOrder/addEval/:orderSn/:orderGoodsId",
            name: "AddEval",
            meta: {
              title: "评价"
            },
            component: () => import("@/views/mall/evaluation/AddEval.vue")
          },
          {
            path: "certificate",
            name: "Certificate",
            meta: {
              title: "我的证书"
            },
            component: () => import("@/views/certificate/Certificate.vue")
          },
        ]
      },
      {
        path: 'mall/cart',
        name: 'Cart',
        meta: {
          title: "购物车"
        },
        component: () => import('@/views/mall/Cart.vue'),
      },
      {
        path: 'mall/pay',
        name: 'Pay',
        meta: {
          title: "结算"
        },
        component: () => import('@/views/mall/Pay.vue'),
      },
      {
        path: 'mall/thirdPay/:orderSn',
        name: 'ThirdPay',
        meta: {
          title: "付款"
        },
        component: () => import('@/views/mall/ThirdPay.vue'),
      },
      {
        path: "mall/payDone",
        name: "PayDone",
        meta: {
          title: "支付成功"
        },
        component: () => import("@/views/mall/PayDone.vue")
      },
    ]
  },
  {
    path: "/exam/onlineExam/:id",
    name: "OnlineExam",
    meta: {
      title: "在线考试"
    },
    component: () => import("@/views/exam/OnlineExam.vue")
  },
  {
    path: "/exam/userExamResult/examDetail/:id",
    name: "ExamDetail",
    meta: {
      title: "考试结果明细"
    },
    component: () => import("@/views/exam/ExamDetail.vue")
  },
  {
    path: "/login",
    name: "Login",
    meta: {
      title: "登录"
    },
    component: () => import("@/views/Login.vue")
  },


  {
    path: "/register",
    name: "Register",
    meta: {
      title: "用户注册"
    },
    component: () => import("@/views/register/Register.vue")
  },
  {
    path: "/:path(.*)*",
    name: "NotFound",
    meta: {
      title: "404"
    },
    component: () => import("@/views/404.vue")
  }
];

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_PUBLIC_PATH), // hash模式：createWebHashHistory，history模式：createWebHistory
  routes: constantRouterMap
});
export default router;
